#include <algorithm>
#include <cctype>
#include <cstdint>
#include <iostream>
#include <istream>
#include <limits>
#include <string>
#include <tuple>
#include <utility>
#include <vector>


using ll = int64_t;

ll n;
std::string s1,s2;
std::vector<std::vector<std::pair<ll, ll>>> dp;
/*
dp[k][i]=tuple(ll w,ll jt)
k从右往左第k个字符
i减少增加
w消耗的次数
jt 0不变，1进位，-1退位
*/

std::tuple<ll,ll> rw(ll i){
    ll ans{};
    ll jt{};
    char c = s1[i];
    while(c!=s2[i]){
        ans++;
        if(c=='z'){
            jt=1;
            c='a';
            continue;
        }
        c++;
    }
    return {ans,jt};
}
std::tuple<ll,ll> lw(ll i){
    ll ans{};
    ll jt{};
    char c = s1[i];
    while(c!=s2[i]){
        ans++;
        if(c=='a'){
            jt=-1;
            c='z';
            continue;
        }
        c--;
    }
    return {ans,jt};
}

ll setr(char &c){
    ll jt{};
    if(c=='z'){
        c='a';
        jt=1;
    }else{
        c=c+1;
    }
    return jt;
}

ll setl(char &c){
    ll jt{};
    if(c=='a'){
        jt=-1;
        c='z';
    }else{
        c=c-1;
    }
    return jt;
}

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    std::cin>>n>>s1>>s2;

    s1=' '+s1;
    s2=' '+s2;
    dp.resize(s1.size()+1,std::vector<std::pair<ll, ll>>(2,std::pair<ll, ll>(std::numeric_limits<ll>::max(),0)));
    dp[s1.size()][0].first = dp[s1.size()][1].first = 0;
    for(ll k=s1.size()-1;k>=1;k--){
        ll nw{};
        if(isupper(s1[k]) != isupper(s2[k])){
            nw++;
        }
        s1[k]=tolower(s1[k]);
        s2[k]=tolower(s2[k]);
        for(ll i=0;i<(ll)dp[k+1].size();i++){
            if(dp[k+1][i].second==1){
                ll jt = setr(s1[k]);
                auto[tlw,tljt] = lw(k);
                auto[trw,trjt] = rw(k);
                dp[k][0].first=std::min(dp[k][0].first,tlw+dp[k+1][i].first+nw);
                if(dp[k][0].first==tlw+dp[k+1][i].first+nw)dp[k][0].second=tljt+jt;
                dp[k][1].first=std::min(dp[k][1].first,trw+dp[k+1][i].first+nw);
                if(dp[k][1].first==trw+dp[k+1][i].first+nw)dp[k][1].second=trjt+jt;
                setl(s1[k]);
            }else if(dp[k+1][i].second==-1){
                ll jt = setl(s1[k]);
                auto[tlw,tljt] = lw(k);
                auto[trw,trjt] = rw(k);
                dp[k][0].first=std::min(dp[k][0].first,tlw+dp[k+1][i].first+nw);
                if(dp[k][0].first==tlw+dp[k+1][i].first+nw)dp[k][0].second=tljt+jt;
                dp[k][1].first=std::min(dp[k][1].first,trw+dp[k+1][i].first+nw);
                if(dp[k][1].first==trw+dp[k+1][i].first+nw)dp[k][1].second=trjt+jt;
                setr(s1[k]);
            }else{
                auto[tlw,tljt] = lw(k);
                auto[trw,trjt] = rw(k);
                dp[k][0].first=std::min(dp[k][0].first,tlw+dp[k+1][i].first+nw);
                if(dp[k][0].first==tlw+dp[k+1][i].first+nw)dp[k][0].second=tljt;
                dp[k][1].first=std::min(dp[k][1].first,trw+dp[k+1][i].first+nw);
                if(dp[k][1].first==trw+dp[k+1][i].first+nw)dp[k][1].second=trjt;
            }
        }
    }

    std::cout<<std::min(dp[1][0].first,dp[1][1].first)<<'\n';
}